package com.assessment.controller;

import com.assessment.common.api.Result;
import com.assessment.model.dto.UserLoginDTO;
import com.assessment.model.vo.UserInfoVO;
import com.assessment.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户控制器
 */
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 微信登录
     */
    @PostMapping("/wxLogin")
    public Result<UserInfoVO> wxLogin(@RequestBody UserLoginDTO loginDTO) {
        UserInfoVO userInfo = userService.wxLogin(loginDTO);
        return Result.success(userInfo);
    }

    /**
     * 根据手机号查询用户
     */
    @GetMapping("/getByPhone")
    public Result<UserInfoVO> getByPhone(@RequestParam String phone) {
        UserInfoVO userInfo = userService.getUserByPhone(phone);
        return Result.success(userInfo);
    }
}
